<template>
	<view class="page">
		<view class="bar_info" :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class="title_bar">
				<view class="title_bar_left" @tap.stop="isBack">
					<u-icon size="38" color="#000" name="arrow-left"></u-icon>
				</view>
				<view class="title_bar_center">
					<text>行业资讯</text>
				</view>
				<view class="title_bar_right"></view>
			</view>
		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>

		<view class="loading_css" v-if="isShow">
			<u-loading size="36" color="#0E7EFD"></u-loading>
			<view class="loading_text">加载中</view>
		</view>

		<view class="list" v-else>
			<view class="advice_list">
				<view class="list_item" v-for="(v, k) in list" :key="k" @tap.stop="goDetails(v.id)">
					<view class="item_left">
						<view class="item_left_1">
							{{v.title}}
						</view>
						<view class="item_left_2">
							<view class="item_left_2_1">
								<text class="tips">{{v.author}}</text>
								<text>{{v.create_time}}</text>
							</view>
							<view @tap.stop="button">
								<button class="item_left_2_2" open-type="share">
									分享
									<image src="/static/index/4.png" mode=""></image>
								</button>
							</view>
						</view>
					</view>
					<view class="item_right">
						<u-lazy-load :image="v.thumb" mode="aspectFill" border-radius="8"></u-lazy-load>
					</view>
				</view>
			</view>
			<u-loadmore v-if="last_page > 1" class="loadmore" font-size="24" :status="status"
				:icon-type="iconType" :load-text="loadText" />
			<view class="noData" v-if="list.length == 0 && !isShow">
				<image src="/static/empty/no.png"></image>
				<view>没有银行卡~</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				image: '/static/index/3.png',
				isShow: true,
				card_cate_id: "",  // 分类id
				list: [],
				"page": 1,
				"is_pull": true,
				"last_page": 1,
				"status": 'loadmore',
				"iconType": 'flower',
				"loadText": {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '我也是有底线的'
				},
				
			}
		},
		onLoad(option) {
			let { id } = option;
			if (id !== undefined) this.card_cate_id = id; 
			this.getList();
		},
		onShareAppMessage(res) {
			if (res.from === 'button') { // 来自页面内分享按钮
				console.log(res.target)
			}
			return {
				title: '爱尚积分',
				path: '/pages/index/information'
			}
		},
		// 下拉刷新
		onPullDownRefresh() {
			this.page = 1;
			this.is_pull = true;
			this.isShow = true;
			this.getList();
		},
		// 上拉加载
		onReachBottom() {
			if (this.page >= this.last_page) return;
			this.status = 'loading';
			this.page++;
			setTimeout(() => {
		
				if (this.page >= this.last_page) this.status = 'nomore';
				else this.status = 'loading';
				this.is_pull = false;
				this.getList();
			}, 500)
		},
		methods: {
			// 更多行业资讯
			getList() {
				this.$api.post(global.apiUrls.postArticle, {
					cate_id: 1,
					page: this.page,
					from: 'other'
				}).then(res => {
					// console.log(res);
					uni.stopPullDownRefresh();
					this.isShow = false;
					if (res.data.code == 1) {
						this.last_page = res.data.data.last_page;
						if (this.is_pull) {
							this.list = res.data.data.data;
						} else {
							this.list = this.list.concat(res.data.data.data);
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			button() {
				
			},
			goDetails(id) {
				uni.navigateTo({
					url: '/pages/share/index?id=' + id
				})
			},
			isBack() {
				uni.navigateBack();
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fff !important;
	}
	.page {
		background-color: #fff !important;
		.bar_info {
			width: 750rpx;
			height: 88rpx;
			overflow: hidden;
			// border-bottom: 1px solid #eee;
			// background: #fff;
			z-index: 10;
			position: fixed;
			top: 0rpx;

			.title_bar {
				padding: 0 32rpx;
				display: flex;
				justify-content: space-between;

				.title_bar_left {
					width: 50rpx;
					display: flex;
					align-items: center;
				}

				.title_bar_center {
					line-height: 88rpx;
					font-size: 36rpx;
					font-weight: 400;
				}

				.title_bar_right {
					width: 50rpx;
				}
			}
		}

		.list {
			padding:0 30rpx;
			
			
			.advice_list {
				// margin-top: 16rpx;
				.list_item {
					display: flex;
					padding: 32rpx 0;
					border-bottom: 1rpx solid #eee;
			
					.item_left {
						padding: 0 28rpx 0 15rpx;
						width: calc(100% - 202rpx);
						.item_left_1 {
							height: 82rpx;
							font-size: 32rpx;
							font-weight: 400;
							line-height: 44rpx;
							text-overflow: ellipsis;
							overflow: hidden;
							display: -webkit-box;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 2;   /* 这里是超出几行省略 */
						}
						.item_left_2 {
							margin-top: 39rpx;
							display: flex;
							justify-content: space-between;
							align-items: center;
							.item_left_2_1 {
								font-size: 24rpx;
								color: #999;
								display: flex;
								justify-content: space-between;
								align-items: center;
								text {
									margin-right: 29rpx;
								}
								.tips {
									max-width: 100rpx;
									text-overflow: ellipsis;
									overflow: hidden;
									display: -webkit-box;
									-webkit-box-orient: vertical;
									-webkit-line-clamp: 1;
								}
							}
							.item_left_2_2 {
								font-size: 24rpx;
								color: #0278FC;
								display: flex;
								justify-content: center;
								align-items: center;
								height: 32rpx;
								width: 84rpx;
								background: #fff;
								line-height: 32rpx;
								padding: 0;
								margin: 0;
								image {
									width: 25rpx;
									height: 25rpx;
									margin-left: 12rpx;
									vertical-align: middle;
								}
							}
							.item_left_2_2::after {
								border: none;
							}
						}
					}
			
					.item_right {
						width: 202rpx;
						height: 145rpx;
			
						/deep/.u-lazy-item {
							width: 202rpx !important;
							height: 145rpx !important;
						}
					}
				}
			}
		}
	}
</style>